﻿<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="tabRefundsReturns.ascx.cs" Inherits="CustomerService.tabRefundsReturns" %>
<script type="text/javascript" language="javascript">
    function btnNewRma_click() {
        var orderID = document.getElementById('<%=txtOrderID.ClientID %>').value;
        TearOff("NewRMA.aspx?OrderID=" + orderID + "&PanelID=<%= RefundsAndReturnsPanel.UniqueID %>", "NewRMA", "600", "400");
    }

    function btnNewRefund_click() {
        var orderID = document.getElementById('<%=txtOrderID.ClientID %>').value;
        TearOff("NewRefund.aspx?OrderID=" + orderID + "&PanelID=<%= RefundsAndReturnsPanel.UniqueID %>", "NewRefund", "600", "400");
    }
</script>
<asp:TextBox style="display:none;" ID="txtOrderID" runat="server" />
<asp:UpdatePanel ID="RefundsAndReturnsPanel" runat="server">
<ContentTemplate>
    <table id="refunds" cellpadding="3" cellspacing="0" class="ItemList">
        <tr>
            <td>
                Item
            </td>
            <td>
                Charged
            </td>
            <td>
                Refunded
            </td>
        </tr>
        <asp:ListView ID="ListViewRefunds" runat="server" DataKeyNames="RefundID">
            <LayoutTemplate>
                <tr id="itemPlaceholder" runat="server"></tr>
            </LayoutTemplate>
            <ItemTemplate>
                <tr>
                    <td>
                        <%# Eval("LineDescription")%>
                    </td>
                    <td>
                        <%# Eval("OrderDetail.TotalPrice")%>
                    </td>
                    <td>
                        <%# Eval("Cost")  %>
                    </td>
                </tr>
            </ItemTemplate>
        </asp:ListView>
        <tr>
            <td colspan="3">
                <input type="button" id="btnNewRefund" value="New Refund" onclick="btnNewRefund_click();" />
            </td>
        </tr>
    </table>
    <table id="returns" cellpadding="3" cellspacing="0" class="ItemList">
        <tr>
            <td>
                Item
            </td>
            <td>
                Qty Shipped
            </td>
            <td>
                RMA
            </td>
            <td>
                RMA Issued on
            </td>
            <td>
                Received on
            </td>
            <td>
                Qty Returned
            </td>
        </tr>
        <asp:ListView ID="ListViewReturns" runat="server" DataKeyNames="ReturnDetailID">
            <LayoutTemplate>
                <tr id="itemPlaceholder" runat="server"></tr>
            </LayoutTemplate>
            <ItemTemplate>
                <tr>
                    <td>
                        <%# Eval("OrderDetail.Product.ItemCode")  %>
                    </td>
                    <td>
                        <%# Eval("OrderDetail.Qty")  %>
                    </td>
                    <td>
                        <%# Eval("RMAReturnId")  %>
                    </td>
                    <td>
                        <%# ((DateTime)Eval("RMAReturn.IssueDate")).ToShortDateString()  %>
                    </td>
                    <td>
                        <%# (Eval("RMAReturn.ReceiptDate") == null) ? string.Empty : ((DateTime)Eval("RMAReturn.ReceiptDate")).ToShortDateString()  %>
                    </td>
                    <td>
                        <%# Eval("Qty")  %>
                    </td>
                </tr>
            </ItemTemplate>
        </asp:ListView>
        <tr>
            <td colspan="6">
                <input type="button" id="btnNewRma" onclick="btnNewRma_click();" value="New RMA" runat="server" />
                &nbsp&nbsp&nbsp
                <asp:Button ID="btnReceiveReturns" runat="server" Text="Receive Returns" />
            </td>
        </tr>
    </table>
</ContentTemplate>
</asp:UpdatePanel>